# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=fisher
pkgver=1.0.0
pkgrel=3
pkgdesc="Simple yet powerful webhooks catcher"
url="https://github.com/pietroalbini/fisher"
arch="x86_64 armv7 armhf aarch64 x86 ppc64le"  # limited by rust/cargo
license="GPL-3.0-or-later"
makedepends="cargo cargo-auditable"
install="$pkgname.pre-install"
subpackages="$pkgname-openrc"
source="https://github.com/pietroalbini/$pkgname/archive/v$pkgver/$pkgname-$pkgver.tar.gz
	config.patch
	minimize-size.patch
	gitlab-hook-job.patch
	$pkgname.initd
	$pkgname.logrotate
	"
options="!check"  # problems with test dependencies


prepare() {
	default_prepare

	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --frozen --release
}

package() {
	install -m 755 -D target/release/fisher "$pkgdir"/usr/bin/fisher

	install -m 644 -D config-example.toml "$pkgdir"/etc/fisher/config.toml
	install -m 755 -D "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname

	install -m 644 -D "$srcdir"/$pkgname.logrotate \
		"$pkgdir"/etc/logrotate.d/$pkgname

	install -d -m 755 "$pkgdir"/etc/fisher/scripts
}

sha512sums="c1f98aefa6f2a5d4ffca37ec4faed192e874bbd62a8eed131081569a23f259781905d1d73735846585c26faf6d0e80860b12c229d8e5cdfc0c4780fd87be6aa6  fisher-1.0.0.tar.gz
3663fef2852bb3d8f706bf1eab881b137b45e2f69eb42657b5d53d1cc6dcab511c8503747c1209b7e4245b249bef0988ee2fc4f8d3f1d49402a8e063f497fd1c  config.patch
7b5bfd8a9e5a6bdd8c8ad08bcd0fa0c11ba89ecc9f44ad39e8a327568b3b62da2ce359ea4f1896141e1df5bcc2ddd3821ad207b02100d8536a7918b8d9d82331  minimize-size.patch
f715819d5efb7388ecd898fea58304d9da50a02b7c3db06e5d9f86410be4377d76e8acb70cbb7bad8ed3e0abd192c920a09bc4b99191c88f1c92e6435d1d42bd  gitlab-hook-job.patch
93a0ef4af30dbd07ba76f99d6f29d9ac16df9805861239bb658d6d39d69b606cd12611459c0b0fc108ed2b7ecd3dd01e7c64b2a9f1cd8b4eb914fa87261ad261  fisher.initd
5e76707439c2e30c96fd7c94017e9e61f8892e988cb6d3776bf858b5f6e5247b87c35964a1af53c041fe18409eb2b939e5103630216a68d94f3fcce982896660  fisher.logrotate"
